<%@ page contentType="text/html;charset=utf-8"%>
<%@ page
	import="java.io.*, java.sql.*, java.util.*, java.text.*, napal.*, util.*, napal.*"%>
<%@ page import="org.apache.ibatis.*"%>
<%@ page import="java.util.Date"%>
<%
	request.setCharacterEncoding("utf-8");
%>


<%@ include file="./Header.jsp"%></td>
</TR>
<% 	
String m = (String)session.getAttribute("managerID");

	if(m==null){ %>
<script language=javascript>
			self.window.alert("권한이 없습니다.");
			location.href="Main.jsp?";
		</script>
<%}
	
		if ("수정".equals(request.getParameter("cmd"))) {
						String n = request.getParameter("m1");
						int aid = Integer.parseInt(n);
						String n2 = request.getParameter("Mtext");
						String n3 = request.getParameter("Ctext");
						RentalHome.Mupdate(aid, n2,n3);
				%>
				<script language=javascript>
				self.window.alert("정보를 수정하였습니다.");
				location.href="Model.jsp";
			</script>
			 <%
 	}
 	%>

 
 	<%
			if ("삭제".equals(request.getParameter("cmd"))&&RentalHome.Model2(request.getParameter("m"))==null) {

							RentalHome.Mdelete(request.getParameter("m"));
				%>
				<script language=javascript>
				self.window.alert("정보를 삭제하였습니다.");
				location.href="Model.jsp";
			</script> <%}%>
			
				<%
			if ("삭제".equals(request.getParameter("cmd"))&&RentalHome.Model2(request.getParameter("m"))!=null) {%>
				<script language=javascript>
				self.window.alert("기자재가 존재하여 삭제 할 수없습니다.");
				location.href="Model.jsp";
			</script> <%}%>
			
			
<TR HEIGHT="100"> 
<TD>
<a href="giguan.jsp" class="btn btn-link btn-small">기자재관리<br></a>
  ><a href="Model.jsp" class="btn btn-link btn-small">모델관리<br></a><br><br>
<p align="left"><a href="./ModelEnroll.jsp" class="btn btn-inverse" style="width: 90">새로등록</a></p>
<table  class="table table-bordered">
<tr>
<td>
카테고리명
</td>
<td>
</td>
<td>
모델명
</td>
<td>
</td>
</tr>
<% for (EM g: RentalHome.Model()) {
	%>
	<form  method="POST">
	<input type=hidden name="m1" value="<%=g.get모델번호()%>">
	<input type=hidden name="m" value="<%=g.get모델명()%>">
	<TR>
	<td>
	<%=g.get카테고리명() %>
	</td>
	<td>
	<input name="Ctext" type="text" value="<%=g.get카테고리명() %>">
	</td>
	<td>
	<%=g.get모델명() %>
		</td>
	<td>
	<input name="Mtext" type="text" value="<%=g.get모델명() %>">
	</td>
	<td>
	<input name="cmd" class="btn btn-inverse" type=submit value="수정"  style="width: 50">
	<input name="cmd" class="btn btn-inverse" type=submit value="삭제"  style="width: 50">
	</td>
	</tr>
	</form> 
	<%} %>
</table>
	</td>
</TR>
<TR HEIGHT="50">
<TD><%@ include file="./bottom.jsp"%></TD> 
</TR>
</TABLE>

</body>
</html>
